home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / pleas / ole / excel / dialog.txt < prev    next >
Encoding:
Text File  |  1994-06-10  |  774 b   |  33 lines

  1. ' Calling an Excel dialog from VB
  2. ' 1. create an Excel workbook called SHEETS.XLS
  3. ' 2. open a dialog sheet
  4. ' 3. add a listbox
  5.  
  6. Dim APPXL As object
  7. Dim XL As object
  8. Dim wb As object
  9. Dim dlg As object
  10. Dim dlgList As object
  11. Dim objList As object
  12.  
  13. Set APPXL = GetObject(, "Excel.Application")
  14. Set XL = APPXL.Application
  15. XL.Workbooks.Open "SHEETS.XLS"
  16. Set wb = XL.ActiveWorkbook
  17. Set Dlg = wb.DialogSheets("dialog1")
  18. Set DlgList = dlg.ListBoxes("sheetsList")
  19. Set objList = wb.Sheets
  20. dlgList.RemoveAllItems
  21. dlg.DialogFrame.Caption = "List of Sheets"
  22. For ix = 1 To objList.count
  23.     dlgList.[AddItem] (objList(ix).name)
  24. Next
  25. dlg.[Show]
  26.  
  27. Set dlg = Nothing
  28. Set dlgList = Nothing
  29. Set objList = Nothing
  30. Set wb = Nothing
  31. Set XL = Nothing
  32. Set APPXL = Nothing
  33.